package com.wan37.client.message.received;

import com.google.protobuf.Message;
import com.wan37.protobuf.constant.CommonBackpack;
import com.wan37.protobuf.constant.PtoNum;
import com.wan37.protobuf.message.client2server.game.GameBackpack;
import com.wan37.protobuf.message.client2server.game.GameEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * @author : luoyong
 * @date : 2020-07-20 17:11
 **/
@Component(PtoNum.USERIDTOITEM + "")
public class UserIdToItem implements ReceiveMsg {
    private final static Logger logger = LoggerFactory.getLogger(UserIdToItem.class);

    @Override
    public void execute(Message msg) {
        GameBackpack.UserIdToItem userIdToItem = (GameBackpack.UserIdToItem) msg;
        switch (userIdToItem.getCode()) {
            case CommonBackpack.UPDATE_ITEM_REDUCE_COUNT:
                for (GameEntity.stringMsg stringMsg : userIdToItem.getRoleIdList()) {
                    logger.info("{}：对 {} 使用了 {}物品。", userIdToItem.getUserId(),
                            stringMsg.getStringId(), userIdToItem.getItemId());
                }
                break;
            default:
                break;
        }
    }
}
